import { createRouter, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

NProgress.configure({ showSpinner: false })

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/Home.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login.vue'),
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('@/views/Register.vue'),
    },
    {
      path: '/movie/:id',
      name: 'movie-detail',
      component: () => import('@/views/MovieDetail.vue'),
    },
    {
      path: '/cinemas',
      name: 'cinema-list',
      component: () => import('@/views/CinemaList.vue'),
    },
    {
      path: '/movies',
      name: 'movie-list',
      component: () => import('@/views/MovieList.vue'),
    },
    {
      path: '/cinema/:id',
      name: 'cinema-detail',
      component: () => import('@/views/CinemaDetail.vue'),
    },
    {
      path: '/me/saves',
      name: 'my-saves',
      component: () => import('@/views/MySaves.vue'),
    },
    {
      path: '/me/orders',
      name: 'my-orders',
      component: () => import('@/views/MyOrders.vue'),
    },
    {
      path: '/me/comments',
      name: 'my-comments',
      component: () => import('@/views/MyComments.vue'),
    },
    {
      path: '/me/profile',
      name: 'my-profile',
      component: () => import('@/views/MyProfile.vue'),
    },
  ],
})

router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

router.afterEach(() => {
  NProgress.done()
})

export default router
